package com.yuandian.utils.poi;

import cn.hutool.core.util.ObjectUtil;
import com.yuandian.constant.Constants;

import java.util.List;

/**
 * 说明：Excel标题工具类
 * @Author zuokun
 * @Date 2022/02/08 15:09
 */
public class ExcelTitleUtils {
    /**
     * 根据条件生成标题名
     */
    public static String formTitleName(List<String> params, String startTime, String endTime){
        String formTitleName = "";
        for (String param : params) {
            if (param != null && param != ""){
                formTitleName += param + "-";
            }
        }
        //去除最后一个"-"
        formTitleName = formTitleName.substring(0,formTitleName.length() - 1);
        //添加时间
        formTitleName = formTitleName + "  " + startTime + "~" + endTime;
        return formTitleName;
    }

    /**
     * 根据条件生成标题名
     */
    public static String formTitleName(List<String> params, String startTime){
        String formTitleName = "";
        for (String param : params) {
            if (ObjectUtil.isNotEmpty(param)){
                formTitleName += param + "-";
            }
        }
        //去除最后一个"-"
        formTitleName = formTitleName.substring(0,formTitleName.length() - 1);
        //添加时间
        formTitleName = formTitleName + Constants.DOUBLE_SPACE + startTime;
        return formTitleName;
    }
}
